package cxydmmszl.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;

/**
 * 工具类
 *
 * @author habitplus
 * @since 2021-08-28 10:53
 */
public interface Util {
    /**
     * 链表的节点
     */
    public static class LNode {
        int val;
        LNode next;

        public LNode(int val) {
            this.val = val;
        }
    }

    /**
     * 单链表的节点
     */
    public static class Node {
        int val;
        Node next;

        public Node(int val) {
            this.val = val;
        }
    }

    /**
     * 双向链表的节点
     */
    public static class DoubleNode {
        int val;
        DoubleNode prev;
        DoubleNode next;

        public DoubleNode(int val) {
            this.val = val;
        }
    }

    /**
     * 二叉树的节点
     */
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }

    /*
     * 尾插法
     */
    public static Node genLinkedListByTail(int[] arr) {
        if (arr == null || arr.length < 1) {
            return null;
        }

        Node tou = new Node(0), pre = tou, node;
        for (int val : arr) {
            node = new Node(val);
            pre.next = node;
            pre = node;
        }

        return tou.next;
    }

    /*
     * 头插法
     */
    public static Node genLinkedListByHead(int[] arr) {
        if (arr == null || arr.length < 1) {
            return null;
        }

        Node next = null, node;
        for (int i = arr.length - 1; i >= 0; i--) {
            node = new Node(arr[i]);
            node.next = next;
            next = node;
        }

        return next;
    }

    public static DoubleNode genDoubleLinkedList01(int[] arr) {
        if (arr == null) {
            return null;
        }

        DoubleNode nxt = null, cur;
        for (int i = arr.length - 1; i >= 0; i--) {
            cur = new DoubleNode(arr[i]);
            if (nxt != null) {
                nxt.prev = cur;
                cur.next = nxt;
            }
            nxt = cur;
        }

        return nxt;
    }

    public static DoubleNode genDoubleLinkedList(int[] arr) {
        if (arr == null || arr.length < 1) {
            return null;
        }

        DoubleNode tou = new DoubleNode(0), pre = tou, cur;
        for (int v : arr) {
            cur = new DoubleNode(v);
            cur.prev = pre;
            pre.next = cur;
            pre = cur;
        }
        tou.next.prev = null;

        return tou.next;
    }

    public static void printLinkedList(Node head) {
        StringBuilder sb = new StringBuilder();
        while (head != null) {
            sb.append(head.val).append(" ");
            head = head.next;
        }
        System.out.println(sb.toString());
    }

    public static void printDoubleLinkedList(DoubleNode head) {
        StringBuilder sb = new StringBuilder();
        while (head != null) {
            sb.append(head.val).append(" ");
            head = head.next;
        }
        System.out.println(sb.toString());
    }

    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        int[] arr = new int[n];
        String[] ss = bf.readLine().split(" ");

        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ss[i]);
        }

        // write your code

    }
}
